package statistic;

import database.DatabaseHelper;
import entity.Course;
import entity.Score;
import entity.Section;
import entity.Student;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.function.Supplier;
import java.util.stream.Stream;

public class CourseScoreList {
    public ArrayList<Course> courses = new ArrayList<>();
    public ArrayList<Section> sections = new ArrayList<>();
    public ArrayList<Score> scores = new ArrayList<>();
    public double total = 0;

    public CourseScoreList(Student stu) throws SQLException {
        DatabaseHelper db = new DatabaseHelper();
        for (Section sec: stu.getSections(db)) {
            courses.add(sec.getCourse(db));
            sections.add(sec);
            Score sco = Score.find(db, sec, stu);
            scores.add(sco);
            total += sco.getTotal();
        }
        db.close();
    }
}
